<?php
include_once("include/public.php");
$menu = 3;
$smarty->assign("menu",$menu);
$id = GETD('id');
$tid = GETD('tid');
$type = $db->query_row("select id,title from case_type order by idx,id desc",MYSQL_ASSOC);
$smarty->assign("type",$type);
$typeName = array(0=>"网站建设",1=>"企业形象平面设计",2=>"3D建模",3=>"影视后期");
$pageTitle = "{$typeName[$tid]}-案例展示-";
$typeTitle = $typeName[$tid];
$smarty->assign("pageTitle",$pageTitle);
$smarty->assign("typeTitle",$typeTitle);
$smarty->assign("tid",$tid);
$smarty->assign("id",$id);

$page = GETD('page');
if($page>0)
{
	$page--;	
}
$perpage = 12;
if($id!=0)
{
	$case = $db->get_one("select title,brief,brief_img,url,time from tcase where id=$id",MYSQL_ASSOC);
	$imgs = $db->query_row("select img from case_img where pid=$id",MYSQL_ASSOC);
	$smarty->assign("case",$case);
	$smarty->assign("imgs",$imgs);
	$smarty->display('case_detail.html');
}
else
{
	$sql = "select id,title,brief,brief_img,time from tcase where tid=($tid+1)";
	$total = sizeof($db->query_row($sql,MYSQL_ASSOC));
	$sql.=" order by time desc,id asc limit ".($page*$perpage).",$perpage";
	$case = $db->query_row($sql,MYSQL_ASSOC);
	$p = new WPagenavE();
	$p->file	= $_SERVER["SCRIPT_NAME"];
	$p->pvar	= "page";	//设置页面传递的参数，默认为p	  
	$p->Query 	= "tid=$tid";
	$p->set($perpage,$total);
	$smarty->assign("case",$case);
	$smarty->assign("p",$p->output);	
	$smarty->display("case.html");
}
?>